/**
 * 断面单项
 */
Ext.define('Admin.view.waterOptimum.resultshow.sectionSingle',{
	extend:'Ext.panel.Panel',
	xtype:'woSectionSingle',
	//起别名
	alias:'woSectionSingle',
	require:[],
	user:[],
	userCLs:'big-100 small-100',
	layout: {
        type: 'hbox',
        align: 'stretch'
    },
	items:[{
		xtype: 'panel',
		flex: 1,
		layout: {
	        type: 'vbox',
	        align: 'stretch'
	    },
		items: [{
			xtype: 'wohighchart',
			border: false,
			flex:1
		},{
			xtype: 'wohighchart',
			border: false,
			flex:1
		}]
	},{
		xtype: 'grid',
		border: true,
	    margin: '0 10 10 30',
	    store: Ext.data.StoreManager.lookup('sample4s_s1'),
	    columns: [
	    		{ text: '时间', dataIndex: 'index1', width: '19%', minWidth: 100, align: 'center' },
	        { text: '流量', dataIndex: 'index2', width: '20%', minWidth: 100, align: 'center', renderer:
							function customRound(value, record){
								if(value == null)return null;
								return Ext.util.Format.round(value, 3);
							}
					},
	        { text: '最小生态流量', dataIndex: 'index3', width: '20%', minWidth: 100, align: 'center', renderer:
							function customRound(value, record){
								if(value == null)return null;
								return Ext.util.Format.round(value, 3);
							}
					},
	        { text: '水位', dataIndex: 'index4', width: '20%', minWidth: 100, align: 'center', renderer:
							function customRound2(value, record){
								if(value == null)return null;
								return Ext.util.Format.round(value, 2).toFixed(2);
					} },
	        { text: '最低水位', dataIndex: 'index5', width: '20%', minWidth: 100, align: 'center', renderer:
							function customRound2(value, record){
								if(value == null)return null;
								return Ext.util.Format.round(value, 2).toFixed(2);
					} }
	    ],
	    flex: 1
	}],
	getChartConfig1: function(){
		return {
		    title: {
		        text: '流量过程图'
		    },
		    xAxis: {
		        categories: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月']
		    },
		    yAxis: {
		        title: {
		            text: '流量m³/s'
		        }
		    },
		    tooltip: {
	            shared: true,
	            crosshairs: true,
	            valueDecimals: 3
	        },
		    series: [{
		        name: '流量',
		        data: [] //getDataArray(store4s_s1, 'index2', 0, 12)
		    }, {
		        name: '最小生态流量',
		        data: [] // getDataArray(store4s_s1, 'index3', 0, 12)
		    }]	
		};
	},
	getChartConfig2: function(){
		return {
		    chart: {
		    	type: 'area',
		    	spacingBottom: 30,
		    	animation: {
	                duration: 600
	            },
				events: {
	                load: function () {
	                    // set up the updating of the chart each second
	                    var series = this.series[0];

	                    /*Ext.util.TaskManager.stopAll(true);
	                    sectionSingleTimer1 = {
	                		run: function() {
	                			if(!sectionSingleReady)return;
	                        	var value = getSectionSingleTimelyData(scedfl)*40;

	                        	series.data[1].update(value);
	                        	series.data[2].update(value);
	                        	series.data[3].update(value);
	                        	series.data[4].update(value);
	                        	var kapTitle = '水位过程图 ['+(store4s_1.getAt(scedfl).get('index1'))+']';
	                        	//	console.log(kapTitle);
	                        	chartSectionSingle2.setTitle({text: kapTitle});
	                        	scedfl++;
	                        	if(scedfl >= 12)scedfl = 0;
	                		},
	                		interval: 2000
	                    };
	                    Ext.util.TaskManager.start(sectionSingleTimer1);*/
	                    /*if(sectionSingleTimer1 != null)window.clearInterval(sectionSingleTimer1);
	                    sectionSingleTimer1 = setInterval(function () {
	                    	if(!sectionSingleReady)return;
	                    	var value = getSectionSingleTimelyData(scedfl)*100;

	                    	series.data[1].update(value);
	                    	series.data[2].update(value);
	                    	series.data[3].update(value);
	                    	series.data[4].update(value);
	                    	var kapTitle = '水位过程图 ['+(store4s_1.getAt(scedfl).get('index1'))+']';
	                    	//	console.log(kapTitle);
	                    	chartSectionSingle2.setTitle({text: kapTitle});
	                    	scedfl++;
	                    	if(scedfl >= 12)scedfl = 0;
	                    }, 2000);*/
	                }
	            }
		    },
			title: {
		        text: '水位过程图'
		    },
		    xAxis: {
		        categories: ['0', '30', '60', '90', '120', '150'],
		        visible: false
		    },
		    yAxis: {
		        title: {
		            text: '水位m'
		        },
		        visible: false
		    },
		    legend:{
		    	enabled: false
		    },
		    plotOptions: {
		    	area: {
		    		marker: {
		    			enabled: false
		    		},
		    		allowPointSelect: false,
		    		enableMouseTracking: false
		    	}
		    },
		    tooltip: {
		    	enabled: false
		    },
		    series: [{
		    	name: '水位',
		    	fillOpacity: 0.5,
		        data: [null, 2000, 2000, 2000, 2000, null],
		        fillColor: '#97CBFF',
		        lineColor: '#0080FF'
		    },{
		    	name: '水位',
		    	fillOpacity: 1,
		        data: [4000, 4000, 0,0,4000,4000],
		        tooltip: false
		    }]
		};
	}
});
